package com.mxpio.erp.common.equipment.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.technology.entity.ItemGroup;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

/**
 * @Description: 设备维修
 * @Author: chenqiang
 * @Date:   2021-09-23
 * @Version: V1.0
 */
@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_REPAIR")
@Schema(description="设备维修")
public class EquipmentRepair  extends BaseEntity {

	/**主键*/
    @Id
    @Generator
    @Column(name = "ID_", updatable = false)
    @Schema(description = "ID")
    private String id;
	/**工单编码*/
    @Column(name = "ORDER_CODE_")
    @Schema(description = "工单编码")
    private String orderCode;
	/**目标类别*/
    @Dict(dicCode = "ERP_EQUIPMENT_REPAIR_TARGET")
    @Column(name = "TARGET_TYPE_")
    @Schema(description = "目标类别")
    private String targetType;
    /**作业组织类型*/
//    @Dict(dictTable = "v_depart_group", dicText = "name", dicCode = "id")
    @Dict(dicCode="id", dicEntity = ItemGroup.class, dicText = "name")
    @Column(name = "ORG_ID_")
    @Schema(description = "作业组织")
    private String orgId;
    /**作业组织类型*/
    @Dict(dicCode = "ERP_EQUIPMENT_TASK_ORG_TYPE")
    @Column(name = "TASK_ORG_TYPE_")
    @Schema(description = "作业组织类型")
    private String taskOrgType;
	/**目标ID*/
    @Column(name = "TARGET_ID_")
    @Schema(description = "目标ID")
    private String targetId;
	/**设备/区域名称*/
    @Column(name = "TARGET_NAME_")
    @Schema(description = "设备/区域名称")
    private String targetName;
	/**设备/区域编码*/
    @Schema(description = "设备/区域编码")
    @Column(name = "TARGET_CODE_")
    private String targetCode;
	/**工单状态*/
    @Dict(dicCode = "ERP_EQUIPMENT_REPAIR_STATUS")
    @Schema(description = "工单状态")
    @Column(name = "ORDER_STATUS_")
    private Integer orderStatus;
	/**申请人*/
    @Dict(dicEntity = User.class, dicText = "nickname", dicCode = "username")
    @Schema(description = "申请人")
    @Column(name = "APPLY_ID_")
    private String applyId;
	/**申请人工号*/
    @Schema(description = "申请人工号")
    @Column(name = "APPLY_NO_")
    private String applyNo;
	/**申请时间*/
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @Schema(description = "申请时间")
    @Column(name = "APPLY_TIME_")
    private java.util.Date applyTime;
	/**故障发生时间*/
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @Schema(description = "故障发生时间")
    @Column(name = "FAILURE_DATE_")
    private java.util.Date failureDate;
	/**数据来源类别*/
    @Schema(description = "数据来源类别")
    @Column(name = "SOURCE_TYPE_")
    private String sourceType;
	/**负责人*/
    @Dict(dicEntity = User.class, dicText = "nickname", dicCode = "username")
    @Schema(description = "负责人")
    @Column(name = "RECE_PERSON_ID_")
    private String recePersonId;
	/**负责人工号*/
    @Schema(description = "负责人工号")
    @Column(name = "RECE_PERSON_NO_")
    private String recePersonNo;
	/**维修类别(ABC)*/
    @Dict(dicCode = "ERP_EQUIPMENT_REPAIR_TYPE")
    @Schema(description = "维修类别(ABC)")
    @Column(name = "ABC_TYPE_")
    private String abcType;
	/**故障描述*/
    @Schema(description = "故障描述")
    @Column(name = "EXISTING_PROBLEMS_")
    private String existingProblems;
	/**进度要求*/
    @Schema(description = "进度要求")
    @Column(name = "REQUIRED_PROGRESS_")
    private String requiredProgress;
    /**现场图片*/
    @Schema(description = "现场图片")
    @Column(name = "PIC_")
    private String pic;
	/**计划开工时间*/
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @Schema(description = "计划开工时间")
    @Column(name = "PLAN_REPAIR_START_DATE_")
    private java.util.Date planRepairStartDate;
	/**计划结束时间*/
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @Schema(description = "计划结束时间")
    @Column(name = "PLAN_REPAIR_END_DATE_")
    private java.util.Date planRepairEndDate;
    /**验收时间*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @Schema(description = "验收时间")
    @Column(name = "CHECK_TIME_")
    private java.util.Date checkTime;
	/**分配时间*/
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @Schema(description = "分配时间")
    @Column(name = "DISTRIBUTE_TIME_")
    private java.util.Date distributeTime;
    /**验收人*/
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    @Schema(description = "验收人")
    @Column(name = "CHECK_USER_")
    private String checkUser;
    /**任务接收时间*/
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @Schema(description = "任务接收时间")
    @Column(name = "RECE_TIME_")
    private java.util.Date receTime;
	/**工时定额（计划工时）*/
    @Schema(description = "工时定额（计划工时）")
    @Column(name = "HOUR_RATION_")
    private String hourRation;
	/**任务分配人*/
    @Dict(dicEntity = User.class, dicText = "nickname", dicCode = "username")
    @Schema(description = "任务分配人")
    @Column(name = "DISTRIBUTE_PERSON_ID_")
    private String distributePersonId;
	/**外协标志：整体外协：Y；否：N；部分外协：P*/
    @Schema(description = "外协标志：整体外协：Y；否：N；部分外协：P")
    @Column(name = "CONSIGN_FLAG_")
    private String consignFlag;
	/**是否紧急工单*/
    @Dict(dicCode = "MB_SYSTEM_YES_NO")
    @Schema(description = "是否紧急工单")
    @Column(name = "EMERGENCY_FLAG_")
    private Integer emergencyFlag;
	/**紧急联系电话*/
    @Schema(description = "紧急联系电话")
    @Column(name = "CHK_PERSON_PHONE_")
    private String chkPersonPhone;
    /**紧急联系人*/
    @Schema(description = "紧急联系人")
    @Column(name = "CHK_PERSON_")
    private String chkPerson;
	/**实际开始时间*/
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @Schema(description = "实际开始时间")
    @Column(name = "ACTUAL_START_DATE_")
    private java.util.Date actualStartDate;
	/**实际结束时间*/
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @Schema(description = "实际结束时间")
    @Column(name = "ACTUAL_END_DATE_")
    private java.util.Date actualEndDate;
	/**任务分配明细*/
    @Schema(description = "任务分配明细")
    @Column(name = "TASK_DESCRIBE_")
    private String taskDescribe;
	/**任务过程总结描述*/
    @Schema(description = "任务过程总结描述")
    @Column(name = "MAITAIN_SUMMARY_")
    private String maitainSummary;
	/**故障維修确认描述*/
    @Schema(description = "故障維修确认描述")
    @Column(name = "REPAIR_CONFIRM_DESC_")
    private String repairConfirmDesc;
	/**是否有派工人员反馈记录,1表示有,0或null表示没有*/
    @Schema(description = "是否有派工人员反馈记录,1表示有,0或null表示没有")
    @Column(name = "IS_FEEDBACK_")
    private Integer isFeedback;
    /**是否逾期*/
    @Dict(dicCode = "MB_SYSTEM_YES_NO")
    @Schema(description = "是否逾期")
    @Column(name = "OVER_FLAG_")
    private Integer overFlag;
	/**逾期原因描述*/
    @Schema(description = "逾期原因描述")
    @Column(name = "OVERDUE_REASON_")
    private String overdueReason;

    /**流程状态*/
    @Schema(description = "流程状态")
    @Column(name = "BPM_STATUS_")
    private String bpmStatus;
    /**派工模式*/
    @Dict(dicCode = "ERP_EQUIPMENT_DISPATCH_MODE")
    @Schema(description = "派工模式")
    @Column(name = "DISPATCH_MODE_")
    private String dispatchMode;

    /**维修工时*/
    @Schema(description = "维修工时(分钟)")
    @Column(name = "WORK_MINUTES_")
    private Long workMinutes;

    @Transient
    @Schema(description = "转派原因")
    private String reason;

    /**评价星级*/
    @Schema(description = "评价星级")
    @Column(name = "EVALUATE_STAR_")
    private Integer evaluateStar;

    /**位置*/
    @Column(name = "ADDRESS_")
    @Schema(description = "位置")
    private String address;

    //评价相关字段--开始
    @Column(name = "IS_USABLE_")
    @Schema(description = "是否可用")
    @Dict(dicCode = "ERP_COMMON_YESNO")
    private Integer isUsable;

    /*@Column(name = "EVALUATE_SCORE_")
    @Schema(description = "评分")
    private String evaluateScore;*/

    @Column(name = "EVALUATE_CONTENT_")
    @Schema(description = "评价描述")
    private String evaluateContent;

    @Column(name = "EVALUATE_DATE_")
    @Schema(description = "评价时间")
    private Date evaluateDate;
    /**验收人*/
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    @Schema(description = "评分人")
    @Column(name = "EVALUATE_USER_")
    private String evaluateUser;

    @Column(name = "EVALUATE_IMG_")
    @Schema(description = "评价图片")
    private String evaluateImg;
    //评价相关字段--结束

    //结单相关字段 开始
    @Column(name = "MALFUNCTION_REASON_")
    @Schema(description = "故障原因")
    private String malfunctionReason;

    @Column(name = "MALFUNCTION_HANDLING_")
    @Schema(description = "处理内容")
    private String malfunctionHandling;

    @Column(name = "MALFUNCTION_IMG_")
    @Schema(description = "现场图片")
    private String malfunctionImg;
    //结单相关字段 结束

    @Column(name = "FAULT_TYPE_CODE_")
    @Schema(description = "故障类型")
    @Dict(dicCode = "typeCode", dicEntity = FaultType.class, dicText = "typeName")
    private String faultTypeCode;


    @Transient
    private List<EquipmentRepairUrgeLine> urgeLineList;
    @Transient
    private FaultType faultType;
}
